#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0-or-later
#
# DESCR: Check that path patterns in MAINTAINERS have trailing slash

use strict;
use warnings;

open( my $file, "<", "MAINTAINERS" ) or die "Error: could not open file 'MAINTAINERS'\n";

while ( my $line = <$file> ) {
	if ( $line =~ /^[FX]:\s+([^\s]*[^*\/\s])\s+$/ ) {  # path patterns not ending with / or *
		my $path = $1;

		if ( -d $path ) {
			print "MAINTAINERS:$. missing trailing slash for directory match ";
			print "`$path`\n";
		}
	}
}

close($file);
